using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper.Contrib.Extensions;
using Publicuse.Entity.AttributeUtil;
using Publicuse.Entity.AttributeUtil.Validate;
using SqlSugar;

namespace Publicuse.Entity
{
  /// <summary>
  /// 角色信息
  /// </summary>
  [DBTable("`geeker-role`", "角色信息")]
  [Table("`geeker-role`")]
  //[Table("geeker-role", Schema = "road")]
  [Schema("geeker")]
  [SugarTable("`geeker-role`")]
  public partial class Role : BaseModel<long>
  {
    [Remark("名称")]
    //[IntValues("必须是1,2,3其中一个", 1, 2, 3)]
    [Length(1, 7, "字符长度最小为1最大为7")]
    [Format("^[\u4e00-\u9fa5]+$", "只包含汉字")]
    public string rName { get; set; }

    [Remark("角色编码")]
    public string rCode { get; set; }

    [Remark("上级ID")]
    public int parentId { get; set; } = -1;

    [Remark("所属上级")]
    [NoQuery]
    [NoInsert]
    [NoUpdate]
    [Write(false)]
    [SugarColumn(IsIgnore = true)]
    public string pName { set; get; }

    [SugarColumn(IsIgnore = true)]
    [NoQuery]
    public string parentName { get; set; }

    [SugarColumn(IsIgnore = true)]
    [NoQuery]
    public bool ischecked { get; set; }

    [SugarColumn(IsIgnore = true)]
    [NoQuery]
    public string resName { get; set; }

    [SugarColumn(IsIgnore = true)]
    [NoQuery]
    public int statusb { get; set; }

    [SugarColumn(IsIgnore = true)]
    [NoQuery]
    public long aId { get; set; }

    public Role()
    {
      this.Id = 0;
      
    }
  }

  public class RoleExtend : Role
  {
    [NoQuery]
    public string parentName { get; set; }

    [NoQuery]
    public bool ischecked { get; set; }
  }

  public class RoleTree : Role
  {
    public List<Role> children { get; set; } = new List<Role>();
  }

  /// <summary>
  /// 角色查询参数
  /// </summary>
  public class RoleQuery : CommonQuery
  {
    public int rId { get; set; }

    public string rName { get; set; }

    public RoleQuery()
    {
      this.exportName = GetExportName;
      this.businessType = BusinessType.role;
    }

    public static string GetExportName
    {
      get { return "role"; }
    }
  }
}
